/**
 * Created by Administrator on 2016-10-26.
 */
var login={
    check: function () {
        var username=$('input[name="username"]').val();
        var password=$('input[name="password"]').val();
        if(!username&&!password){
            dialog.error("用户名和密码不能为空！");
            return;
        }else if(!password){
            dialog.error("密码不能为空！");
            return;
        }else if(!username){
            dialog.error("用户名不能为空！");
            return;
        }
        $.post('/index.php/admin/login',{
            '_token':$('.csrf_token').val(),
            'username':username,
            'password':password
        },function(data){
            if(data.res){
                var _url="/index.php/admin/home";
                dialog.success("登录成功！",_url);
            }else{
                dialog.error("登录失败!");
            }
        }).error(function(e){
            dialog.error("登录失败!");
        });
    }
};
